module CertificateJsonSerializer
  def self.as_json certificate
    # certificate.to_json(include: [:require_organs])
    certificate.attributes.merge({require_organs: PositionCertificateStandard.find_require_organ_by_certificate(certificate)}).
                           merge(PositionCertificateStandard.find_employees_by_certificate(certificate))
  end

  def self.analysis_as_json certificates
    certificates.map { |e| as_json(e) }
  end  
end